package com.secxiot.api.task;

import com.secxiot.common.entity.ResultVo;
import com.secxiot.common.exception.BaseException;
import com.secxiot.provider.task.dto.TaskDto;
import com.secxiot.provider.task.dto.TaskSosDto;
import com.secxiot.provider.task.dto.TaskTransferListDto;
import com.secxiot.provider.task.dto.TaskVisitDto;
import com.secxiot.provider.task.vo.*;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@RequestMapping(value = "/tasks")
@RestController
public interface TaskApi {

    /**
     * 获取用户给定时间段任务
     *
     * @param userId   用户id
     * @param pageNo   页码，0开始
     * @param pageSize 请求数量
     * @param since    开始时间
     * @param last     结束时间，不传默认到当前最新
     * @return
     */
    @GetMapping
    TaskHomeVo listUnfinishedByUserIdAndTime(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize,
            @RequestParam(value = "since", required = true) Date since,
            @RequestParam(value = "last", required = false) Date last);

    /**
     * 发布任务
     *
     * @param taskDto 任务内容
     * @return
     */
    @PostMapping
    Long publish(@RequestBody TaskDto taskDto);

    /**
     * 发布交接任务
     *
     * @param taskTransferListDto 交接任务内容
     * @return 任务id
     */
    @PostMapping("transfer")
    Long publish(@RequestBody TaskTransferListDto taskTransferListDto);

    /**
     * 发布SOS任务
     *
     * @param sosDto SOS任务内容
     * @return 任务id
     */
    @PostMapping("sos")
    Long publishSosTask(@RequestBody TaskSosDto sosDto) throws BaseException;

    /**
     * 发布出诊任务
     *
     * @param visitDto SOS出诊任务内容
     * @return 任务id
     */
    @PostMapping("visit")
    Long publishSosVisit(@RequestBody TaskVisitDto visitDto) throws BaseException;

    /**
     * 获取任务状态信息
     *
     * @return 任务状态信息
     */
    @GetMapping("/sos/status")
    TaskSOSStatusVo getSOSTaskStatusByPatientId(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskId", required = false) Long taskId) throws BaseException;

    /**
     * 获取SOS疾病症状
     *
     * @param userId 用户id
     * @return
     * @throws BaseException
     */
    @GetMapping("/sos/diseases")
    List<SosDiseaseVo> getDisease(
            @RequestParam(value = "userId", required = true) Long userId) throws BaseException;

    /**
     * 更新任务状态信息
     *
     * @param userId        用户id
     * @param taskId        任务id
     * @param confirmStatus 状态
     * @return 任务状态信息
     * @throws BaseException
     */
    @PostMapping("status")
    TaskStatusUpdateVo updateStatus(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskId", required = true) Long taskId,
            @RequestParam(value = "confirmStatus", required = true) String confirmStatus
    ) throws BaseException;

    /**
     * 获取患者检测数据模版
     *
     * @param deptId 部门id
     * @return 患者检测数据模版列表
     */
    @GetMapping("/transfer/temp")
    List<TaskTempVo> getTaskTemp(
            @RequestParam(value = "deptId", required = true) Long deptId);

    /**
     * 获取已发布任务
     *
     * @param userId   用户id
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 已发布任务列表
     */
    @GetMapping("/published")
    List<TaskDisplayVo> getPublishedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取我的科室任务
     *
     * @param deptId   部门id
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 我的科室任务列表
     */
    @GetMapping("/depart")
    List<TaskDisplayVo> getDepartmentList(
            @RequestParam(value = "deptId", required = true) Long deptId,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取按任务类型区分的已发布任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 已经发布的各种任务类型的列表
     */
    @GetMapping("/released")
    List<TaskDisplayVo> getReleasedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 任务统计数据
     *
     * @param userId 用户id
     * @param deptId 部门id
     * @return
     */
    @GetMapping("/statistics")
    TaskStatisticsVo getStatistics(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "deptId", required = false) Long deptId,
            @RequestParam(value = "year", required = true) Integer year,
            @RequestParam(value = "month", required = false) Integer month
    );

    /**
     * 获取按任务类型区分的已接收任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @param pageNo   页码
     * @param pageSize 条数
     * @return 已经接收的各种任务类型的列表
     */
    @GetMapping("/received")
    List<TaskDisplayVo> getReceivedList(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType,
            @RequestParam(value = "pageNo", required = true) Long pageNo,
            @RequestParam(value = "pageSize", required = true) Long pageSize
    );

    /**
     * 获取任务统计数据
     *
     * @param type     任务类型(1:接收; 2:发布)
     * @param userId   用户ID
     * @param dateTime 时间节点
     * @return
     */
    @GetMapping("/taskCount")
    TaskCountResultVo getTaskCountResultVo(
            @RequestParam(value = "type", required = true) Integer type,
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "dateTime", required = true) Date dateTime
    );

    /**
     * 获取各种类型的最新一条任务
     *
     * @param userId   用户id
     * @param taskType 任务类型
     * @return 一条该类型的最新任务
     */
    @GetMapping("/newest")
    TaskDisplayVo getNewestTask(
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "taskType", required = true) String taskType
    );

    /**
     * 首页按类型区分的最新任务、未确认数量
     *
     * @param userId 用户id
     * @return 各种类型的最新任务、未确认数量
     */
    @GetMapping("/taskHome")
    TaskAndConfirmStatusVo getNewestTaskAndStatus(
            @RequestParam(value = "userId", required = true) Long userId
    );

    /**
     * 搜索任务
     *
     * @param userId     用户id
     * @param searchName 发布人&内容 搜索
     * @param taskType   任务类型
     * @param type       搜索类型(1:接收; 2:发布)
     * @param pageNo     页码
     * @param pageSize   条数
     * @return
     */
    @GetMapping("/searchTask")
    List<TaskDisplayVo> getSearchTaskList(@RequestParam(value = "userId", required = true) Long userId,
                                          @RequestParam(value = "searchName", required = true) String searchName,
                                          @RequestParam(value = "taskType", required = false) String taskType,
                                          @RequestParam(value = "type", required = true) Integer type,
                                          @RequestParam(value = "pageNo", required = true) Long pageNo,
                                          @RequestParam(value = "pageSize", required = true) Long pageSize);

    /**
     * 获取对应的sos任务ID
     *
     * @param taskId 出诊任务ID
     * @param userId
     * @return
     */
    @GetMapping("/getSosTaskId")
    Long getSosTaskId(@RequestParam(value = "taskId", required = true) Long taskId,
                      @RequestParam(value = "userId", required = true) Long userId);

    /**
     * sos 上报位置
     *
     * @param taskId
     * @param longitude
     * @param latitude
     */
    @PostMapping("/sosReportLocation")
    Long sosReportLocation(@RequestParam(value = "userId", required = true) Long userId,
                           @RequestParam(value = "taskId", required = true) Long taskId,
                           @RequestParam(value = "longitude", required = true) BigDecimal longitude,
                           @RequestParam(value = "latitude", required = true) BigDecimal latitude);

    /**
     * 获取医院救护车位置
     *
     * @param hospitalId 医院id
     * @return
     */
    @GetMapping("/sosAmbulanceLocation")
    List<SosPlatformVo> sosAmbulanceLocation(@RequestParam(value = "hospitalId", required = true) Long hospitalId);

    /**
     * 获取车辆列表
     *
     * @return
     */
    @GetMapping("/sosAmbulanceList")
    List<RemindAmbulanceVo> getAmbulanceVoList(@RequestParam(value = "hospitalId", required = true) Long hospitalId);

    /**
     * 增加任务车辆记录
     *
     * @return
     */
    @PostMapping("/saveTaskAmbulance")
    TaskStatusUpdateVo saveTaskAmbulance(@RequestParam(value = "userId", required = true) Long userId,
                                         @RequestParam(value = "taskId", required = true) Long taskId,
                                         @RequestParam(value = "ambulanceId", required = true) Long ambulanceId,
                                         @RequestParam(value = "confirmStatus", required = true) String confirmStatus) throws BaseException;

    /**
     * 发送视频请求
     *
     * @param taskId 任务id
     * @return
     */
    @GetMapping("/videoStatus")
    int updateReportVideoTask(@RequestParam(value = "taskId", required = true) Long taskId,
                              @RequestParam(value = "userId", required = true) Long userId,
                              @RequestParam(value = "videoStatus", required = true) Integer videoStatus);
}
